package com.honey.serializable;

import org.java.plugin.Plugin;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.core.Extension;
import com.honey.core.callback.CallbackCompilation;
import com.honey.core.compiler.Compilation;
import com.honey.core.compiler.CompilationDescriptor;
import com.honey.core.compiler.ContentType;
import com.honey.core.notify.Notify;
import com.honey.core.notify.Signal;

public class SerializableExtension extends Extension<Plugin> implements CallbackCompilation , Notify {
	private SerializablePlugin  jsonPlugin = null;
	
	public SerializableExtension(Plugin belongPlugin) {
		super(belongPlugin);
		this.jsonPlugin = (SerializablePlugin)belongPlugin;
	}


	@Override
	public void execute(CompilationDescriptor compilationDescriptor) {
		if(ContentType.JAVA_ENTITY_BEEN ==  compilationDescriptor.getContentType() ){
			SerializableObjectMethod json =SerializableObjectFactory.getAppendToJsonObjectMethod( jsonPlugin.getJsonLibrary() );
			Compilation compilation = compilationDescriptor.getCompilation() ;
			if( compilation instanceof AbstractJavaCompilation ){
				json.appendJsonMethod( (AbstractJavaCompilation) compilation );
			}
		}
	}
	
	@Override
	public void execute(Signal signal) {
		
	}

	@Override
	public void clean() {
		
	}


	@Override
	public Class<Signal>[] supportSignal() {
		return null;
	}
}
